package com.quanyan.comment.init;

import com.quanyan.comment.cache.MyRedisTemplate;
import com.quanyan.comment.mapper.TbSensitiveMapper;
import com.quanyan.comment.model.constant.Constants;
import com.quanyan.comment.model.po.TbSensitive;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * Created by Administrator on 2017/4/7.
 */
@Component
public class SensitiveInit implements CommandLineRunner {

    @Autowired
    private TbSensitiveMapper tbSensitiveMapper;

    @Autowired
    private MyRedisTemplate myRedisTemplate;


    @Override
    public void run(String... strings) throws Exception {
        this.init();
    }

    public void init(){
        List<TbSensitive> list = tbSensitiveMapper.selectByExample(null);
        myRedisTemplate.set(Constants.SENSITIVE_KEY,list);
    }
}
